<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/7/15
  Time: 15:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>显示所有用户信息</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="./static/css/bootstrap.min.css" >

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="./static/css/bootstrap-theme.min.css">
    <script src="./static/js/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="./static/js/bootstrap.min.js" ></script>
    <style>
        .head_image{
            width: 100px;
            height: 50px;
        }
    </style>
</head>
<body>
<div>
    <!-- 添加用户信息按钮 -->
    <a href="user?request_type=toAddPage" class="btn btn-primary mb-3">添加用户信息</a>

    <!-- 显示所有用户信息的表格 -->
    <table class="table table-bordered table-responsive">
        <thead>
        <tr>
            <th scope="col">用户编号</th>
            <th scope="col">用户名</th>
            <th scope="col">用户昵称</th>
            <th scope="col">用户头像</th>
            <th scope="col">性别</th>
            <th scope="col">用户类型</th>
            <th scope="col">个性签名</th>
            <th scope="col">最后登录时间</th>
            <th scope="col">创建时间</th>
            <th scope="col">操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${userList}" var="user">
            <tr>
                <td>${user.id}</td>
                <td>${user.user_name}</td>
                <td>${user.nick_name}</td>
                <td> <img src="${user.head_image_thumb}" class="head_image"> </td>
                <td> <c:if test="${!user.sex}">男</c:if>
                    <c:if test="${user.sex}">女</c:if>
                </td>
                <td>
                    <c:if test="${user.type==1}">普通用户</c:if>
                    <c:if test="${user.type==2}">管理员</c:if>
                </td>
                <td>${user.signature}</td>
                <td>${user.last_login_time}</td>
                <td>${user.created_time}</td>
                <td style="width: 190px">
                    <!-- 编辑按钮 -->
                    <button type="button" class="btn btn-primary">查看</button>
                    <button type="button" class="btn btn-warning"><a href="user?request_type=toUpdatePage&id=${user.id}">编辑</a></button>
                    <!-- 删除按钮 -->
                    <button type="button" class="btn btn-danger" onclick="deleteById(${user.id})" >删除</button>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
</body>
<script>
        function deleteById(userid) {
            if (confirm("确定删除吗？")) {
                console.log(userid)
                window.location.href = "user?request_type=delete&id=" + userid;
            }
        }
</script>
</html>
